import React, { Component } from 'react'
import Alertbox from '../components/Alert'

export class Home extends Component {
  constructor(props) {
    super(props)

    this.state = {
      flag: false //点击添加--控制弹框显示隐藏
    }
  }

  // 点击关闭弹窗 
  closeFn() {
    this.setState({
      flag: false
    })
  }
  render() {
    const { flag } = this.state;
    return (
      <div>
        <button onClick={() => {
          this.setState({
            flag: true //点击让弹框展示
          })
        }}>添加标签</button>

        {/* 第一个大弹框  */}
        <Alertbox
          flag={flag} //控制弹框状态的开关
          closeFn={this.closeFn.bind(this)}
        ></Alertbox>
      </div>
    )
  }
}

export default Home